fix: Recover handler errors, turn into HTTP 500 response (port from akka-http PR #4242)#1017
Draft
pjfanning wants to merge 2 commits into
Draft
fix: Recover handler errors, turn into HTTP 500 response (port from akka-http PR #4242)#1017pjfanning wants to merge 2 commits into
pjfanning wants to merge 2 commits into
Conversation
…esponse Agent-Logs-Url: https://github.com/pjfanning/incubator-pekko-http/sessions/07445f4c-4a78-42e1-9171-822591dff635 Co-authored-by: pjfanning <11783444+pjfanning@users.noreply.github.com>
Member
|
Failing on this part of the spec: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port of akka/akka-http#4242 to Pekko HTTP.
Now Apache licensed. https://github.com/akka/akka-http/releases/tag/v10.5.1
References: akka/akka-http#4241
Summary
When an HTTP/2 handler throws an exception (either synchronously or by failing a Future), the server previously propagated that error in a way that could tear down the connection. This change wraps the user-provided handler to catch both synchronous and asynchronous errors, converting them into HTTP 500 Internal Server Error responses, keeping the connection alive for further requests.
Changes
Http2.scala: AddedwithErrorHandlingmethod that wraps the user handler to recover fromNonFatalexceptions (sync throws and Future failures), returning an HTTP 500 response and logging the error. The wrapped handler is used for both HTTP/1 upgrade handling and the HTTP/2 stream handler.Http2HighlevelServerSpec.scala(new): Integration test verifying that when a handler fails, the server returns HTTP 500 and the connection remains usable for subsequent requests.All imports and config keys updated from
akka.*topekko.*namespace.